<template>
  <div id="lottery">
    <div>
      <el-date-picker
        class="edge"
        style="width:180px"
        size="mini"
        @change="getSTime"
        value-format="yyyy-MM-dd"
        format="yyyy-MM-dd"
        v-model="daytime"
        type="date"
        placeholder="下注时间"
      ></el-date-picker>
      <el-button size="mini" type="primary" @click="fetchData">查询</el-button>
    </div>

    <!-- 列表 -->
    <div class="edge">
      <el-table size="mini" :data="tableData" border style="width: 100%">
        <el-table-column prop="module" label="彩种" width="80"></el-table-column>
        <el-table-column prop="issue" label="期数" width="150"></el-table-column>
        <el-table-column prop="updateTime" label="开盘时间"></el-table-column>
        <el-table-column prop="createTime" label="封盘时间"></el-table-column>
        <el-table-column prop="openTime" label="开奖时间"></el-table-column>
        <el-table-column prop="splice" label="万" width="80">
          <template slot-scope="scope">
            <span class="n1" v-if="scope.row.type">{{scope.row.num.split("")[0]}}</span>
            <span class="n2" v-else>{{scope.row.num.split("")[0]}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="qian" label="千" width="80">
          <template slot-scope="scope">
            <span class="n1"  @click="aaa(scope.row)" v-if="scope.row.type">{{scope.row.num.split("")[1]}}</span>
            <span class="n2" v-else>{{scope.row.num.split("")[1]}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="bai" label="百" width="80">
          <template slot-scope="scope">
            <span class="n1" v-if="scope.row.type">{{scope.row.num.split("")[2]}}</span>
            <span class="n2" v-else>{{scope.row.num.split("")[2]}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="shi" label="十" width="80">
          <template slot-scope="scope">
            <span class="n1" v-if="scope.row.type">{{scope.row.num.split("")[3]}}</span>
            <span class="n2" v-else>{{scope.row.num.split("")[3]}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="ge" label="个" width="80">
          <template slot-scope="scope">
            <span v-if="scope.row.type" class="n1">{{scope.row.num.split("")[4]}}</span>
            <span v-else class="n2">{{scope.row.num.split("")[4]}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="openTime" label="更新时间"></el-table-column>
      </el-table>
    </div>

    <!-- 分页 -->
    <div>
      <!-- 分页 -->
      <el-pagination
        style="float:right;margin-top:20px"
        size="mini"
        class="pageNumage"
        @current-change="handleCurrentChange"
        background
        layout="prev, pager, next"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import { mapState } from "Vuex";
import moment from 'moment'
export default {
  name: "lottery",
  data() {
    return {
      tableData: [],
      daytime:moment(new Date()).format("YYYY-MM-DD"),
      total: 0,
      pageNum: 1,
      currentPage: 1,
      pritem: this.$route.query.titleid
    };
  },
  created() {
    this.fetchData()
  },
  computed: {
    ...mapState(["typedt"]),
  },
  methods: {
    aaa(num){
     console.log(num,888)
    },
    handleCurrentChange(val) {
      this.pageNum = val;
      this.fetchData();
    },
    // 时间
    getSTime(t) {
      console.log(t, 777);
    },
    // 接口
    fetchData() {
      this.$api.post(
        this.$url.winNumber,
        {
          pageNum: this.pageNum,
          pageSize: 20,
          module: this.typedt,
          day: this.daytime
        },
        res => {
          if (res.data.code == 200) {
            console.log(res.data,"开奖")
            this.tableData = res.data.data;
            this.total = res.data.count;
            this.$set(this.tableData[0], "type", true);
            console.log(this.tableData, "11111");
          } else {
            this.$message.error(res.data.msg);
          }
        }
      );
    }
  }
};
</script>
<style lang="less" scoped>
.edge {
  margin-left: 20px;
  margin-top: 20px;
}
.n1 {
  background: red;
    color: #ffffff;
    border-radius: 50%;
    /* padding: 0 20px; */
    width: 30px;
    height: 30px;
    display: inline-block;
    display: flex;
    align-items: center;
    justify-content: center;
}
.n2 {
  background: blue;
    color: #ffffff;
    border-radius: 50%;
    /* padding: 0 20px; */
    width: 30px;
    height: 30px;
    display: inline-block;
    display: flex;
    align-items: center;
    justify-content: center;
}
</style>